/**
 * Created by lx on 2017/6/26.
 */
app.controller('index.ctrl',['$scope','Candy', function ($scope,Candy) {
    //ajax获取数据
    getindexsList();

    function getindexsList(){
        var promise = Candy.getindexsList();
        promise.then(function (res) {
            $scope.indexsList =res.data ;
            //console.log(typeof (res.data));
            //console.log(res.data);
            //console.log(res.data[1].imgSrc);
        }, function () {
        })
    }
}]);
app.controller('senyong.ctrl',['$scope','Candy', function ($scope,Candy) {
    getsenyongsList();
    function getsenyongsList(){
        var promise = Candy.getsenyongsList();
        promise.then(function (res) {
            $scope.senyongsList = res.data;
        }, function () {
        })
    }
}]);

app.controller('koufulai.ctrl',['$scope','Candy', function ($scope,Candy) {
    getkoufulaisList();
    function getkoufulaisList(){
        var promise = Candy.getkoufulaisList();
        promise.then(function (res) {
            $scope.koufulaisList = res.data;
        }, function () {

        })
    }



}]);

app.controller('youman.ctrl',['$scope','Candy', function ($scope,Candy) {
    getyoumansList();

    function getyoumansList(){
        var promise = Candy.getyoumansList();
        promise.then(function (res) {
            $scope.youmansList = res.data;
        }, function () {

        })
    }


}]);
app.controller('login.ctrl',['$scope', function ($scope){

}]);
app.controller('shoppingcarts.ctrl', ['$scope', 'Candy', '$http', function ($scope, Candy, $http) {
    shoppingcartsInfo();
    function shoppingcartsInfo() {

        var username = '测试2';
        //var username={
        //    username:'测试'
        //}
        Candy.getshoppingcartsInfo(username)
            .then(function (res) {
                $scope.shoppinglists = res.data;
                console.log($scope.shoppinglists[0]);
            }, function () {

            })


    }

    $scope.delpro = function () {
        console.log($scope.shoppinglists[0].pid);
        Candy.delshoppingcartsInfo($scope.shoppinglists[0].pid)
            .then(function (res) {
            var result = res.data.result1;
            console.log(res.data)
            if (result) {
               //$('.cart-model').hide()
                res.send('<div class="shop-top"><ul class="cart-top"><li class="go-back">返回</li><li class="cart-title">购物车</li><li class="home">首页</li></ul></div>')
            }
        }, function () {
            alert('失败')
        })
    }
}]);